package com.playball.lottery.frm.kjinfo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.playball.lottery.R;
import com.playball.lottery.ApplicationData;
import com.playball.lottery.JddMainActivity;
import com.playball.lottery.customview.BallDTO;
import com.playball.lottery.customview.ShowTipDialog;
import com.playball.lottery.frm.buyhall.CQSSCActivity;
import com.playball.lottery.frm.buyhall.CQSSCListActivity;
import com.playball.lottery.frm.buyhall.CtzqRx9Activity;
import com.playball.lottery.frm.buyhall.CtzqSfcActivity;
import com.playball.lottery.frm.buyhall.DltxhActivity;
import com.playball.lottery.frm.buyhall.DltxhlbActivity;
import com.playball.lottery.frm.buyhall.ElvSelFiveActivity;
import com.playball.lottery.frm.buyhall.ElvSelFiveListActivity;
import com.playball.lottery.frm.buyhall.ElvYunDJActivity;
import com.playball.lottery.frm.buyhall.ElvYunDJListActivity;
import com.playball.lottery.frm.buyhall.Fc3dListActivity;
import com.playball.lottery.frm.buyhall.Fc3dxhActivity;
import com.playball.lottery.frm.buyhall.JcBasketballActivity;
import com.playball.lottery.frm.buyhall.JcfootballActivity;
import com.playball.lottery.frm.buyhall.Kuai3Activity;
import com.playball.lottery.frm.buyhall.Kuai3ListActivity;
import com.playball.lottery.frm.buyhall.N7lxhActivity;
import com.playball.lottery.frm.buyhall.N7lxhlbActivity;
import com.playball.lottery.frm.buyhall.N7xxhActivity;
import com.playball.lottery.frm.buyhall.N7xxhlbActivity;
import com.playball.lottery.frm.buyhall.Pailie3ListActivity;
import com.playball.lottery.frm.buyhall.Pailie3xhActivity;
import com.playball.lottery.frm.buyhall.Pailie5ListActivity;
import com.playball.lottery.frm.buyhall.Pailie5xhActivity;
import com.playball.lottery.frm.buyhall.SsqxhActivity;
import com.playball.lottery.frm.buyhall.SsqxhlbActivity;
import com.playball.lottery.nt.orjdd.GetRequestParams;
import com.playball.lottery.util.Constants;
import com.playball.lottery.util.ConvertJsonToList;
import com.playball.lottery.util.DateUtil;
import com.playball.lottery.util.DefConstants;
import com.playball.lottery.util.MyPreference;
import com.playball.lottery.util.PreferencesUtils;
import com.playball.lottery.util.SysApplication;


/**
 * 开奖单个彩种最近十期开奖号码数据列表
 * 
 * @author Administrator
 * 
 */
public class KjinfoListByType extends ListActivity implements DefConstants {
	/** 上下文内容 */
	private Context context = null;
	private TextView main_ui_bottom_title;
	private List<Map<String, Object>> mData;
	private String lottID;
	private String lottName;
	private int titleID;
	private Map<String, Object> detailmData;
	/** 开奖通知选择按钮 */
	CheckBox kjinfo_type_switch_cb;
	private ShowTipDialog showdialog = new ShowTipDialog();

	private Button bet_btn;
	private Button bet_btn1;
	private Intent it;
	private PreferencesUtils pUtil;

	/** 判断是否从推送通知过来 */
	private Boolean ifPush;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.context = this;
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		SysApplication.getInstance().addActivity(this);
		setContentView(R.layout.kjinfo_listbytype);
		pUtil = new PreferencesUtils(this, Constants.PREFERENCES_NAME);
		getIntentData();
		// Log.v("KjinfoListByType", "lottID="+lottID);
		// Log.v("KjinfoListByType", "lottName="+lottName);

		// 标题
		TitleBar();
		// 根据传送过来的LotID确定title的显示
		// Log.d("KjinfoListByType", "lottID= "+lottID.toString());

	}

	@Override
	protected void onNewIntent(Intent intent) {
		// TODO Auto-generated method stub
		super.onNewIntent(intent);
		setIntent(intent);
		getIntentData();
	}

	public void onResume() {
		super.onResume();
		
	}

	public void onPause() {
		super.onPause();
		
	}

	private void getIntentData() {
		Intent intent = getIntent();
		lottID = intent.getStringExtra("LottID");
		lottName = intent.getStringExtra("LottName");
		ifPush = intent.getBooleanExtra("ifPush", false);
		AsyncLoader task = new AsyncLoader();
		task.execute(lottID, "301");

		bet_btn = (Button) findViewById(R.id.bet_btn);
		if (Integer.parseInt(lottID) == 1 || Integer.parseInt(lottID) == 19) {
			bet_btn1 = (Button) findViewById(R.id.bet_btn1);
			bet_btn1.setVisibility(View.VISIBLE);
			bet_btn1.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					it = new Intent();
					it.setClass(KjinfoListByType.this, CtzqRx9Activity.class);
					startActivity(it);
				}
			});
		}
		switch (Integer.parseInt(lottID)) {
		case 1:
		case 19:
			titleID = R.string.kjinfo_number_sfc_rx9;
			bet_btn.setText("胜负彩投注");
			bet_btn1.setText("任选九投注");
			break;
		case 3:
			titleID = R.string.kjinfo_number_qx_info;
			bet_btn.setText("七星彩投注");
			break;
		case 5:
			titleID = R.string.kjinfo_number_s_info;
			bet_btn.setText("双色球投注");
			break;
		case 6:
			titleID = R.string.kjinfo_number_3_info;
			bet_btn.setText("福彩3D投注");
			break;
		case 9:
			titleID = R.string.kjinfo_number_2_info;
			bet_btn.setText("22选5投注");
			break;
		case 13:
			titleID = R.string.kjinfo_number_ql_info;
			bet_btn.setText("七乐彩投注");
			break;
		case 39:
			titleID = R.string.kjinfo_number_d_info;
			bet_btn.setText("大乐透投注");
			break;
		case 63:
			titleID = R.string.kjinfo_number_p3_info;
			bet_btn.setText("排列3投注");
			break;
		case 64:
			titleID = R.string.kjinfo_number_p5_info;
			bet_btn.setText("排列五投注");
			break;
		case 70:
			titleID = R.string.kjinfo_number_1_info;
			bet_btn.setText("11选5投注");
			break;
		case 90:
			titleID = R.string.kjinfo_number_f_info;
			bet_btn.setText("竞彩足球投注");
			break;
		case 91:
			titleID = R.string.jclq_kjinfo_info;
			bet_btn.setText("竞彩篮球投注");
			break;
		case 62:
			titleID = R.string.b11y_kjinfo_info;
			bet_btn.setText("11运夺金投注");
			break;
		case 28:
			titleID = R.string.cqssc_kjinfo_info;
			bet_btn.setText("重庆时时彩投注");
			break;
		case 66:// LOT_ID_KUAI3
			titleID = R.string.kjinfo_number_kuai3_info;
			bet_btn.setText("快三投注");
			break;
		default:
			break;
		}
		main_ui_bottom_title = (TextView) findViewById(R.id.top_title_info);
		main_ui_bottom_title.setText(titleID);

		RelativeLayout kjinfo_listbytype_rlkjnotice = (RelativeLayout) findViewById(R.id.kjinfo_listbytype_rlkjnotice);
		RelativeLayout kjinfo_listbytype_rlseldate = (RelativeLayout) findViewById(R.id.kjinfo_listbytype_rlseldate);
		if (Integer.parseInt(lottID) == LOT_ID_11X5 || Integer.parseInt(lottID) == LOT_ID_11YDJ
				|| Integer.parseInt(lottID) == LOT_ID_CQSSC || Integer.parseInt(lottID) == LOT_ID_KUAI3) {
			kjinfo_listbytype_rlkjnotice.setVisibility(View.GONE);
			// kjinfo_listbytype_rlseldate.setVisibility(View.VISIBLE);
			// 此处无接口暂时 屏蔽
			kjinfo_listbytype_rlseldate.setVisibility(View.GONE);
		} else {
			kjinfo_listbytype_rlkjnotice.setVisibility(View.GONE);
			kjinfo_listbytype_rlseldate.setVisibility(View.GONE);
			kjinfo_type_switch_cb = (CheckBox) findViewById(R.id.kjinfo_type_switch_cb);
			CheckBoxSet();
		}

		bet_btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				it = new Intent();
				switch (Integer.parseInt(lottID)) {
				case 1:
					it.setClass(KjinfoListByType.this, CtzqSfcActivity.class);
					startActivity(it);
					break;
				case 3:
					int n7xx_size = pUtil.getInt("n7xx_size", 0);
					if (n7xx_size != 0) {
						ArrayList<BallDTO> list = new ArrayList<BallDTO>();
						for (int i = 0; i < n7xx_size; i++) {
							BallDTO ball = new BallDTO();
							ball.setPl3_ball(pUtil.getString("n7xx_ball" + i, ""));
							list.add(ball);
						}
						it.putExtra("list_elvdto", list);
						it.putExtra("AllMoney", pUtil.getInt("n7xx_allMoney", 0));
						it.putExtra("PlayTypeID", pUtil.getInt("n7xx_play", 0));
						it.setClass(KjinfoListByType.this, N7xxhlbActivity.class);
						Toast.makeText(KjinfoListByType.this, R.string.this_is_the_last_time_you_save_the_number,
								Toast.LENGTH_SHORT).show();
					} else {
						it.setClass(KjinfoListByType.this, N7xxhActivity.class);
					}
					startActivity(it);
					break;
				case 5:
					int ssq_size = pUtil.getInt("ssq_size", 0);
					if (ssq_size != 0) {
						ArrayList<BallDTO> list = new ArrayList<BallDTO>();
						for (int i = 0; i < ssq_size; i++) {
							BallDTO ball = new BallDTO();
							ball.setSsq_ball(pUtil.getString("ssq_ball" + i, ""));
							list.add(ball);
						}
						it.putExtra("list_ssqdto", list);
						it.putExtra("AllMoney", pUtil.getInt("ssq_allMoney", 0));
						it.setClass(KjinfoListByType.this, SsqxhlbActivity.class);
						Toast.makeText(KjinfoListByType.this, R.string.this_is_the_last_time_you_save_the_number,
								Toast.LENGTH_SHORT).show();
					} else {
						it.setClass(KjinfoListByType.this, SsqxhActivity.class);
					}
					startActivity(it);
					break;
				case 6:
					int fc3d_size = pUtil.getInt("fc3d_size", 0);
					if (fc3d_size != 0) {
						ArrayList<BallDTO> list = new ArrayList<BallDTO>();
						for (int i = 0; i < fc3d_size; i++) {
							BallDTO ball = new BallDTO();
							ball.setPl3_ball(pUtil.getString("fc3d_ball" + i, ""));
							list.add(ball);
						}
						it.putExtra("list_elvdto", list);
						it.putExtra("AllMoney", pUtil.getInt("fc3d_allMoney", 0));
						it.putExtra("PlayTypeID", pUtil.getInt("fc3d_play", 0));
						it.setClass(KjinfoListByType.this, Fc3dListActivity.class);
						Toast.makeText(KjinfoListByType.this, R.string.this_is_the_last_time_you_save_the_number,
								Toast.LENGTH_SHORT).show();
					} else {
						it.setClass(KjinfoListByType.this, Fc3dxhActivity.class);
					}
					startActivity(it);
					break;
				case 9:
					break;
				case 13:
					int n7lx_size = pUtil.getInt("n7lx_size", 0);
					if (n7lx_size != 0) {
						ArrayList<BallDTO> list = new ArrayList<BallDTO>();
						for (int i = 0; i < n7lx_size; i++) {
							BallDTO ball = new BallDTO();
							ball.setPl3_ball(pUtil.getString("n7lx_ball" + i, ""));
							list.add(ball);
						}
						it.putExtra("list_elvdto", list);
						it.putExtra("AllMoney", pUtil.getInt("n7lx_allMoney", 0));
						it.putExtra("PlayTypeID", pUtil.getInt("n7lx_play", 0));
						it.setClass(KjinfoListByType.this, N7lxhlbActivity.class);
						Toast.makeText(KjinfoListByType.this, R.string.this_is_the_last_time_you_save_the_number,
								Toast.LENGTH_SHORT).show();
					} else {
						it.setClass(KjinfoListByType.this, N7lxhActivity.class);
					}
					startActivity(it);
					break;
				case 39:
					int dlt_size = pUtil.getInt("dlt_size", 0);
					if (dlt_size != 0) {
						ArrayList<BallDTO> list = new ArrayList<BallDTO>();
						for (int i = 0; i < dlt_size; i++) {
							BallDTO ball = new BallDTO();
							ball.setDlt_ball(pUtil.getString("dlt_ball" + i, ""));
							list.add(ball);
						}
						it.putExtra("list_dltdto", list);
						it.putExtra("AllMoney", pUtil.getInt("dlt_allMoney", 0));
						it.setClass(KjinfoListByType.this, DltxhlbActivity.class);
						Toast.makeText(KjinfoListByType.this, R.string.this_is_the_last_time_you_save_the_number,
								Toast.LENGTH_SHORT).show();
					} else {
						it.setClass(KjinfoListByType.this, DltxhActivity.class);
					}
					ApplicationData.getInstance().setIsDLTZhuiJiaClick(false);
					startActivity(it);
					break;
				case 63:
					int pl3_size = pUtil.getInt("pl3_size", 0);
					if (pl3_size != 0) {
						ArrayList<BallDTO> list = new ArrayList<BallDTO>();
						for (int i = 0; i < pl3_size; i++) {
							BallDTO ball = new BallDTO();
							ball.setPl3_ball(pUtil.getString("pl3_ball" + i, ""));
							list.add(ball);
						}
						it.putExtra("list_elvdto", list);
						it.putExtra("AllMoney", pUtil.getInt("pl3_allMoney", 0));
						it.putExtra("PlayTypeID", pUtil.getInt("pl3_play", 0));
						it.setClass(KjinfoListByType.this, Pailie3ListActivity.class);
						Toast.makeText(KjinfoListByType.this, R.string.this_is_the_last_time_you_save_the_number,
								Toast.LENGTH_SHORT).show();
					} else {
						it.setClass(KjinfoListByType.this, Pailie3xhActivity.class);
					}
					startActivity(it);
					break;
				case 64:
					int pl5_size = pUtil.getInt("pl5_size", 0);
					if (pl5_size != 0) {
						ArrayList<BallDTO> list = new ArrayList<BallDTO>();
						for (int i = 0; i < pl5_size; i++) {
							BallDTO ball = new BallDTO();
							ball.setPl5_ball(pUtil.getString("pl5_ball" + i, ""));
							list.add(ball);
						}
						it.putExtra("list_elvdto", list);
						it.putExtra("AllMoney", pUtil.getInt("pl5_allMoney", 0));
						it.setClass(KjinfoListByType.this, Pailie5ListActivity.class);
						Toast.makeText(KjinfoListByType.this, R.string.this_is_the_last_time_you_save_the_number,
								Toast.LENGTH_SHORT).show();
					} else {
						it.setClass(KjinfoListByType.this, Pailie5xhActivity.class);
					}
					startActivity(it);
					break;
				case 70:
					int esf_size = pUtil.getInt("esf_size", 0);
					if (esf_size != 0) {
						ArrayList<BallDTO> list = new ArrayList<BallDTO>();
						for (int i = 0; i < esf_size; i++) {
							BallDTO ball = new BallDTO();
							ball.setElv_ball(pUtil.getString("esf_ball" + i, ""));
							list.add(ball);
						}
						it.putExtra("list_elvdto", list);
						it.putExtra("AllMoney", pUtil.getInt("esf_allMoney", 0));
						it.putExtra("PlayTypeID", pUtil.getInt("esf_play", 0));
						it.putExtra("prizeIntellChase", pUtil.getInt("esf_prizeIntellChase", 0));
						it.setClass(KjinfoListByType.this, ElvSelFiveListActivity.class);
						Toast.makeText(KjinfoListByType.this, R.string.this_is_the_last_time_you_save_the_number,
								Toast.LENGTH_SHORT).show();
					} else {
						it.setClass(KjinfoListByType.this, ElvSelFiveActivity.class);
					}
					startActivity(it);
					break;
				case 90:
					it.setClass(KjinfoListByType.this, JcfootballActivity.class);
					startActivity(it);
					break;
				case 91:
					it.setClass(KjinfoListByType.this, JcBasketballActivity.class);
					startActivity(it);
					break;
				case 62:
					int eydu_size = pUtil.getInt("eydu_size", 0);
					if (eydu_size != 0) {
						ArrayList<BallDTO> list = new ArrayList<BallDTO>();
						for (int i = 0; i < eydu_size; i++) {
							BallDTO ball = new BallDTO();
							ball.setElv_ball(pUtil.getString("eydu_ball" + i, ""));
							list.add(ball);
						}
						it.putExtra("list_elvdto", list);
						it.putExtra("AllMoney", pUtil.getInt("eydu_allMoney", 0));
						it.putExtra("PlayTypeID", pUtil.getInt("eydu_play", 0));
						it.putExtra("prizeIntellChase", pUtil.getInt("eydu_prizeIntellChase", 0));
						it.setClass(KjinfoListByType.this, ElvYunDJListActivity.class);
						Toast.makeText(KjinfoListByType.this, R.string.this_is_the_last_time_you_save_the_number,
								Toast.LENGTH_SHORT).show();
					} else {
						it.setClass(KjinfoListByType.this, ElvYunDJActivity.class);
					}
					startActivity(it);
					break;
				case 28:
					int cqssc_size = pUtil.getInt("cqssc_size", 0);
					if (cqssc_size != 0) {
						ArrayList<BallDTO> list = new ArrayList<BallDTO>();
						for (int i = 0; i < cqssc_size; i++) {
							BallDTO ball = new BallDTO();
							ball.setElv_ball(pUtil.getString("cqssc_ball" + i, ""));
							list.add(ball);
						}
						it.putExtra("list_elvdto", list);
						it.putExtra("AllMoney", pUtil.getInt("cqssc_allMoney", 0));
						it.putExtra("PlayTypeID", pUtil.getInt("cqssc_play", 0));
						it.putExtra("strPlayType", pUtil.getString("cqssc_type", ""));
						it.putExtra("prizeIntellChase", pUtil.getInt("cqssc_prizeIntellChase", 0));
						it.setClass(KjinfoListByType.this, CQSSCListActivity.class);
						Toast.makeText(KjinfoListByType.this, R.string.this_is_the_last_time_you_save_the_number,
								Toast.LENGTH_SHORT).show();
					} else {
						it.setClass(KjinfoListByType.this, CQSSCActivity.class);
					}
					startActivity(it);
					break;
				case 66:// LOT_ID_KUAI3
					int kuai3_size = pUtil.getInt("kuai3_size", 0);
					if (kuai3_size != 0) {
						ArrayList<BallDTO> list = new ArrayList<BallDTO>();
						for (int i = 0; i < kuai3_size; i++) {
							BallDTO ball = new BallDTO();
							ball.setElv_ball(pUtil.getString("kuai3_ball" + i, ""));
							list.add(ball);
						}
						it.putExtra("list_elvdto", list);
						it.putExtra("AllMoney", pUtil.getInt("kuai3_allMoney", 0));
						it.putExtra("PlayTypeID", pUtil.getInt("kuai3_play", 0));
						it.putExtra("prizeIntellChase", pUtil.getInt("kuai3_prize", 0));
						it.setClass(KjinfoListByType.this, Kuai3ListActivity.class);
						Toast.makeText(KjinfoListByType.this, R.string.this_is_the_last_time_you_save_the_number,
								Toast.LENGTH_SHORT).show();
					} else {
						it.setClass(KjinfoListByType.this, Kuai3Activity.class);
					}
					startActivity(it);
					break;
				default:
					break;
				}

			}
		});
	}

	public class AsyncLoader extends AsyncTask<String, Integer, String> {// 继承AsyncTask

		// 1.准备运行
		protected void onPreExecute() {
			showdialog.showDialog(KjinfoListByType.this);
		}

		// 2.正在后台运行
		@Override
		protected String doInBackground(String... params) {
			String strResult;
			try {
				// 处理后台执行的任务，在后台线程执行
				JSONObject param = new JSONObject();
				param.put("LottID", params[0]);
				// 设置请求action
				String action = params[1];
				// 获取请求返回值
				strResult = GetRequestParams.getRequestResult(param.toString(), action, getApplicationContext());
				return strResult;
			} catch (Exception e) {
				// TODO: handle exception
				Log.e("error", e.toString());
				return null;
			}
		}

		// 3.进度更新
		protected void onProgressUpdate(Integer... progress) {
		}

		// 4.完成后台任务
		protected void onPostExecute(String result) {
			if (result != null) {
				// Toast.LENGTH_LONG).show();
				try {
					JSONTokener jsonParser = new JSONTokener(result);
					JSONObject js = (JSONObject) jsonParser.nextValue();
					// 接下来的就是JSON对象的操作了
					if (Integer.parseInt(js.getString("Code")) == 0) {
						if (!"".equals(js.getString("Data"))) {
							mData = getData(result);
							if (Integer.parseInt(lottID) == LOT_ID_SSQ || Integer.parseInt(lottID) == LOT_ID_DLT
									|| Integer.parseInt(lottID) == LOT_ID_QXC || Integer.parseInt(lottID) == LOT_ID_QLC) {
								if (mData != null && mData.size() > 0) {
									String IssueID = mData.get(0).get("IssueID").toString();
									detailAsyncLoader task = new detailAsyncLoader();
									task.execute(lottID, IssueID, "302");
								}
							}
							for (int i = 0; i < mData.size(); i++) {
								String issue = mData.get(i).get("Issue").toString();
								// issue += "期\t开奖号码";
								issue = "第" + issue + "期  ";
								mData.get(i).put("Issue", issue);
								String winNumber = mData.get(i).get("WinNumber").toString();
								String[] nums = winNumber.split("\\+");
								// mData.get(i).put("Ball", nums[0]);
								mData.get(i).put("Ball", nums[0].replaceAll(",", " "));
								mData.get(i).put("BlueBall", nums.length > 1 ? nums[1].trim() : "");
								mData.get(i).put("EndTime",
										DateUtil.getDateTime3(mData.get(i).get("EndTime").toString()));
							}
							if (Integer.parseInt(lottID) != LOT_ID_SSQ && Integer.parseInt(lottID) != LOT_ID_DLT
									&& Integer.parseInt(lottID) != LOT_ID_QXC && Integer.parseInt(lottID) != LOT_ID_QLC) {
								KjInfoListAdapter adapter = new KjInfoListAdapter(KjinfoListByType.this, mData);
								setListAdapter(adapter);
							}
						} else {
							Toast.makeText(KjinfoListByType.this, R.string.temporarily_no_data, Toast.LENGTH_SHORT)
									.show();
						}
						showdialog.closeDialog();
					} else {
						Toast.makeText(KjinfoListByType.this, js.getString("Data"), Toast.LENGTH_SHORT).show();
					}
				} catch (JSONException ex) {
					// 异常处理代码
					Log.e("error", ex.toString());
				} finally {
					showdialog.closeDialog();
				}
			} else {
				Toast.makeText(KjinfoListByType.this, getString(R.string.problem_01), Toast.LENGTH_LONG).show();
			}
		}

		// 5.完成后操作
		protected void onCancelled() {
		}

	}

	public class detailAsyncLoader extends AsyncTask<String, Integer, String> {// 继承AsyncTask

		// 1.准备运行
		protected void onPreExecute() {
			// showdialog.showDialog(KjinfoListDetail.this);
		}

		// 2.正在后台运行
		protected String doInBackground(String... params) {
			String strResult = null;
			try {
				// 处理后台执行的任务，在后台线程执行
				JSONObject param = new JSONObject();
				param.put("LottID", params[0]);
				param.put("IssueID", params[1]);
				// 设置请求action
				String action = params[2];
				// 获取请求返回值
				strResult = GetRequestParams.getRequestResult(param.toString(), action, getApplicationContext());
			} catch (Exception e) {
				// TODO: handle exception
				Log.e("error", e.toString());
			}
			return strResult;
		}

		// 3.进度更新
		protected void onProgressUpdate(Integer... progress) {
		}

		// 4.完成后台任务
		protected void onPostExecute(String result) {
			if (result != null) {
				// Toast.LENGTH_LONG).show();
				try {
					JSONTokener jsonParser = new JSONTokener(result);
					JSONObject js = (JSONObject) jsonParser.nextValue();
					// 接下来的就是JSON对象的操作了
					if (Integer.parseInt(js.getString("Code")) == 0) {
						if (Integer.parseInt(lottID) == LOT_ID_SSQ || Integer.parseInt(lottID) == LOT_ID_DLT
								|| Integer.parseInt(lottID) == LOT_ID_QXC || Integer.parseInt(lottID) == LOT_ID_QLC) {
							detailmData = getDetailData(result);
							// Log.i("KjinfoListByType",
							// "开奖等级 detailmData= "+detailmData.toString());
							if (detailmData != null && mData != null) {
								for (int i = 0; i < mData.size(); i++) {
									List<Map<String, Object>> awardList = new ArrayList<Map<String, Object>>();
									awardList = ConvertJsonToList.getList(detailmData.get("Wins").toString());

									if (awardList != null && awardList.size() != 0) {
										mData.get(0).put("Zhu", awardList.get(0).get("Count").toString());
										mData.get(0).put("Ydjmoney", awardList.get(0).get("Money").toString());
										mData.get(0).put("Jiangchi", detailmData.get("Balance").toString());
									} else {
										mData.get(0).put("Zhu", "0");
										mData.get(0).put("Ydjmoney", "0");
										mData.get(0).put("Jiangchi", detailmData.get("Balance").toString());
									}
								}
							}

							KjInfoListAdapter adapter = new KjInfoListAdapter(KjinfoListByType.this, mData);
							setListAdapter(adapter);
						}
					} else {
						Toast.makeText(KjinfoListByType.this, js.getString("Data"), Toast.LENGTH_SHORT).show();
					}
				} catch (JSONException ex) {
					// 异常处理代码
					Log.e("error", ex.toString());
				} finally {
					// showdialog.closeDialog();
				}
			} else {
				Toast.makeText(KjinfoListByType.this, getString(R.string.problem_01), Toast.LENGTH_LONG).show();
			}
		}

		// 5.完成后操作
		protected void onCancelled() {
		}
	}

	private Map<String, Object> getDetailData(String strResult) {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			JSONTokener jsonParser = new JSONTokener(strResult);
			JSONObject js = (JSONObject) jsonParser.nextValue();
			map = ConvertJsonToList.getMap(js.getString("Data"));
		} catch (JSONException ex) {
			// 异常处理代码
			// ex.printStackTrace();
		}
		return map;
	}

	private List<Map<String, Object>> getData(String strResult) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		try {
			JSONTokener jsonParser = new JSONTokener(strResult);
			JSONObject js = (JSONObject) jsonParser.nextValue();
			list = ConvertJsonToList.getList(js.getString("Data"));
		} catch (JSONException ex) {
			// 异常处理代码
			// ex.printStackTrace();
		}
		return list;
	}

	@Override
	protected void onListItemClick(ListView list, View view, int position, long id) {
		if (!(lottID.equals("62") || lottID.equals("70") || lottID.equals("28") || lottID.equals("66"))) {// 11选5
																											// --70
																											// 十一运夺金
																											// 28重庆时时彩
																											// 快三66
			Intent intent = new Intent();
			intent.putExtra("LottID", lottID);
			intent.putExtra("LottName", lottName);
			intent.putExtra("IssueID", mData.get(position).get("IssueID").toString());
			intent.putExtra("Issue", mData.get(position).get("Issue").toString().replace("开奖号码", ""));
			intent.setClass(KjinfoListByType.this, KjinfoListDetail.class);
			startActivity(intent);
			super.onListItemClick(list, view, position, id);
		}
	}

	/**
	 * 存储及改变按钮开奖通知
	 */
	public void CheckBoxSet() {
		if (Integer.parseInt(lottID) == LOT_ID_SSQ) {
			if (MyPreference.getInstance(context).isSSQNotice()) {
				kjinfo_type_switch_cb.setChecked(true);
			} else {
				kjinfo_type_switch_cb.setChecked(false);
			}
			kjinfo_type_switch_cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				@Override
				public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
					// TODO Auto-generated method stub
					MyPreference.getInstance(context).setSSQNotice(arg1);
				}
			});
		} else if (Integer.parseInt(lottID) == LOT_ID_DLT) {
			if (MyPreference.getInstance(context).isDLTNotice()) {
				kjinfo_type_switch_cb.setChecked(true);
			} else {
				kjinfo_type_switch_cb.setChecked(false);
			}
			kjinfo_type_switch_cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				@Override
				public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
					// TODO Auto-generated method stub
					MyPreference.getInstance(context).setDLTNotice(arg1);
				}
			});
		} else if (Integer.parseInt(lottID) == LOT_ID_FC3D) {
			if (MyPreference.getInstance(context).isFC3DNotice()) {
				kjinfo_type_switch_cb.setChecked(true);
			} else {
				kjinfo_type_switch_cb.setChecked(false);
			}
			kjinfo_type_switch_cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				@Override
				public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
					// TODO Auto-generated method stub
					MyPreference.getInstance(context).setFC3DNotice(arg1);
				}
			});
		} else if (Integer.parseInt(lottID) == LOT_ID_QLC) {
			if (MyPreference.getInstance(context).isQLCNotice()) {
				kjinfo_type_switch_cb.setChecked(true);
			} else {
				kjinfo_type_switch_cb.setChecked(false);
			}
			kjinfo_type_switch_cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				@Override
				public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
					// TODO Auto-generated method stub
					MyPreference.getInstance(context).setQLCNotice(arg1);
				}
			});
		} else if (Integer.parseInt(lottID) == LOT_ID_PL3) {
			if (MyPreference.getInstance(context).isPL3Notice()) {
				kjinfo_type_switch_cb.setChecked(true);
			} else {
				kjinfo_type_switch_cb.setChecked(false);
			}
			kjinfo_type_switch_cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				@Override
				public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
					// TODO Auto-generated method stub
					MyPreference.getInstance(context).setPL3Notice(arg1);
				}
			});
		} else if (Integer.parseInt(lottID) == LOT_ID_PL5) {
			if (MyPreference.getInstance(context).isPL5Notice()) {
				kjinfo_type_switch_cb.setChecked(true);
			} else {
				kjinfo_type_switch_cb.setChecked(false);
			}
			kjinfo_type_switch_cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				@Override
				public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
					// TODO Auto-generated method stub
					MyPreference.getInstance(context).setPL5Notice(arg1);
				}
			});
		} else if (Integer.parseInt(lottID) == LOT_ID_QXC) {
			if (MyPreference.getInstance(context).isQXCNotice()) {
				kjinfo_type_switch_cb.setChecked(true);
			} else {
				kjinfo_type_switch_cb.setChecked(false);
			}
			kjinfo_type_switch_cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				@Override
				public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
					// TODO Auto-generated method stub
					MyPreference.getInstance(context).setQXCNotice(arg1);
				}
			});
		} else if (Integer.parseInt(lottID) == LOT_ID_ZQ_SFC || Integer.parseInt(lottID) == LOT_ID_ZQ_RX9) {
			if (MyPreference.getInstance(context).isSFCNotice()) {
				kjinfo_type_switch_cb.setChecked(true);
			} else {
				kjinfo_type_switch_cb.setChecked(false);
			}
			kjinfo_type_switch_cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				@Override
				public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
					// TODO Auto-generated method stub
					MyPreference.getInstance(context).setSFCNotice(arg1);
				}
			});
		}

	}

	// TitleBar标题栏
	public void TitleBar() {
		// Title信息(返回+Title)
		Button back = (Button) findViewById(R.id.top_title_back);
		back.getBackground().setAlpha(255);// 透明度0~255透明度值 ，值越小越透明
		back.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				onKeyDown(KeyEvent.KEYCODE_BACK, null);
			}
		});

		// TextView info = (TextView) findViewById(R.id.top_title_info);
		// info.setText(R.string.kjinfo_listtype);

		Button refres = (Button) findViewById(R.id.top_title_refres);
		refres.getBackground().setAlpha(255);
		refres.setVisibility(View.INVISIBLE);
		// refres.setOnClickListener(new View.OnClickListener() {
		// @Override
		// public void onClick(View v) {
		// // TODO Auto-generated method stub
		// AsyncLoader task = new AsyncLoader();
		// task.execute(lottID, "301");
		// }
		// });
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {

		if (keyCode == KeyEvent.KEYCODE_BACK) {
			if(ifPush){
				Intent intent = new Intent(this, JddMainActivity.class);
				startActivity(intent);
			}
			this.finish();

			return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}

	};

	class KjInfoListAdapter extends BaseAdapter {

		private LayoutInflater inflater = null;

		private List<Map<String, Object>> mData;

		public KjInfoListAdapter(Context context, List<Map<String, Object>> mData) {
			inflater = LayoutInflater.from(context);
			this.mData = mData;
		}

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return mData.size();
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(final int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			int lotIdInt = Integer.parseInt(lottID);
			if (lotIdInt == LOT_ID_ZQ_SFC || lotIdInt == LOT_ID_ZQ_RX9) {// sfc
																			// rx9
				sfcViewHolder sfcholder = null;
				sfcholder = new sfcViewHolder();

				LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
				layoutParams.gravity = Gravity.CENTER_VERTICAL;

				String redBTemp = mData.get(position).get("Ball").toString();

				convertView = inflater.inflate(R.layout.kjinfo_main_list_type_sfc, null);
				sfcholder.name = (TextView) convertView.findViewById(R.id.kjinfo_main_list_type_title);
				sfcholder.endtime = (TextView) convertView.findViewById(R.id.kjinfo_item_right_endtime);
				sfcholder.kjinfo_main_list_type_sfc1 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc1);
				sfcholder.kjinfo_main_list_type_sfc2 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc2);
				sfcholder.kjinfo_main_list_type_sfc3 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc3);
				sfcholder.kjinfo_main_list_type_sfc4 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc4);
				sfcholder.kjinfo_main_list_type_sfc5 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc5);
				sfcholder.kjinfo_main_list_type_sfc6 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc6);
				sfcholder.kjinfo_main_list_type_sfc7 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc7);
				sfcholder.kjinfo_main_list_type_sfc8 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc8);
				sfcholder.kjinfo_main_list_type_sfc9 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc9);
				sfcholder.kjinfo_main_list_type_sfc10 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc10);
				sfcholder.kjinfo_main_list_type_sfc11 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc11);
				sfcholder.kjinfo_main_list_type_sfc12 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc12);
				sfcholder.kjinfo_main_list_type_sfc13 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc13);
				sfcholder.kjinfo_main_list_type_sfc14 = (TextView) convertView
						.findViewById(R.id.kjinfo_main_list_type_sfc14);
				// sfcholder.ballblue = (TextView)
				// convertView.findViewById(R.id.kjinfo_main_list_type_info_blue);
				sfcholder.kjinfo_main_list_type_sfc1.setText(redBTemp.substring(0, 1));
				sfcholder.kjinfo_main_list_type_sfc2.setText(redBTemp.substring(1, 2));
				sfcholder.kjinfo_main_list_type_sfc3.setText(redBTemp.substring(2, 3));
				sfcholder.kjinfo_main_list_type_sfc4.setText(redBTemp.substring(3, 4));
				sfcholder.kjinfo_main_list_type_sfc5.setText(redBTemp.substring(4, 5));
				sfcholder.kjinfo_main_list_type_sfc6.setText(redBTemp.substring(5, 6));
				sfcholder.kjinfo_main_list_type_sfc7.setText(redBTemp.substring(6, 7));
				sfcholder.kjinfo_main_list_type_sfc8.setText(redBTemp.substring(7, 8));
				sfcholder.kjinfo_main_list_type_sfc9.setText(redBTemp.substring(8, 9));
				sfcholder.kjinfo_main_list_type_sfc10.setText(redBTemp.substring(9, 10));
				sfcholder.kjinfo_main_list_type_sfc11.setText(redBTemp.substring(10, 11));
				sfcholder.kjinfo_main_list_type_sfc12.setText(redBTemp.substring(11, 12));
				sfcholder.kjinfo_main_list_type_sfc13.setText(redBTemp.substring(12, 13));
				sfcholder.kjinfo_main_list_type_sfc14.setText(redBTemp.substring(13, 14));

				sfcholder.name.setText(mData.get(position).get("Issue").toString());
				// Log.d("kjtype", "mData= "+mData.toString());
				sfcholder.endtime.setText(mData.get(position).get("EndTime").toString());
				convertView.setTag(sfcholder);
				// sfcholder.ballblue.setText(blueBTemp);
			} else {
				ViewHolder holder = null;
				holder = new ViewHolder();

				LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
				layoutParams.gravity = Gravity.CENTER_VERTICAL;
				layoutParams.rightMargin = 5;

				String redBTemp = mData.get(position).get("Ball").toString();
				String blueBTemp = mData.get(position).get("BlueBall").toString();
				// int lotIdInt = Integer.parseInt(lottID);
				if (lotIdInt == 3 || lotIdInt == 6 || lotIdInt == 63 || lotIdInt == 64 || lotIdInt == LOT_ID_CQSSC) {
					char[] cs = redBTemp.toCharArray();
					if (cs.length > 2 && cs[1] != ' ') {
						redBTemp = "";
						for (int i = 0; i < cs.length; i++) {
							if (i == 0) {
								redBTemp = redBTemp + cs[0];
							} else {
								redBTemp = redBTemp + " " + cs[i];
							}
						}
					}
					cs = blueBTemp.toCharArray();
					blueBTemp = "";
					for (int i = 0; i < cs.length; i++) {
						if (i == 0) {
							blueBTemp = blueBTemp + cs[0];
						} else {
							blueBTemp = blueBTemp + " " + cs[i];
						}
					}
				}
				// 双色球、大乐透、七星彩、七乐彩最新开奖的一期需要显示出一等奖的详情以及奖池情况，其他彩种不需要；
				if (lotIdInt == LOT_ID_SSQ && position == 0 || lotIdInt == LOT_ID_DLT && position == 0
						|| lotIdInt == LOT_ID_QXC && position == 0 || lotIdInt == LOT_ID_QLC && position == 0) {// ssq第一个加上奖池
					convertView = inflater.inflate(R.layout.kjinfolist_item, null);
					holder.name = (TextView) convertView.findViewById(R.id.kjinfo_item_name);
					holder.endtime = (TextView) convertView.findViewById(R.id.kjinfo_item_right_endtime);
					holder.ballLayout = (LinearLayout) convertView.findViewById(R.id.kjinfo_item_ball_layout);

					holder.kjinfo_item_yidjzhu = (TextView) convertView.findViewById(R.id.kjinfo_item_yidjzhu);
					holder.kjinfo_item_yidjmoney = (TextView) convertView.findViewById(R.id.kjinfo_item_yidjmoney);
					holder.kjinfo_item_yidjjiangchi = (TextView) convertView
							.findViewById(R.id.kjinfo_item_yidjjiangchi);
					// 一等奖
					holder.kjinfo_item_yidjzhu.setText(mData.get(position).get("Zhu").toString());
					holder.kjinfo_item_yidjmoney.setText(mData.get(position).get("Ydjmoney").toString());
					holder.kjinfo_item_yidjjiangchi.setText(mData.get(position).get("Jiangchi").toString());

					String[] redBall = redBTemp.split(" ");
					for (String ball : redBall) {
						TextView button = (TextView) inflater.inflate(R.layout.kjinfo_item_ball, null);
						button.setText(ball);
						// button.setTextColor(getResources().getColor(R.color.ui_new_btn_yes_normal_solid));
						// button.setBackgroundResource(R.drawable.redball_normal);
						button.setTextColor(getResources().getColor(R.color.white));
						button.setBackgroundResource(R.drawable.redball_selected);
						holder.ballLayout.addView(button, layoutParams);
					}
					String[] blueBall = blueBTemp.split(" ");
					for (String ball : blueBall) {
						if (ball != "") {
							TextView button = (TextView) inflater.inflate(R.layout.kjinfo_item_ball, null);
							button.setText(ball);
							// button.setTextColor(getResources().getColor(R.color.ui_new_btn_no_normal_solid));
							// button.setBackgroundResource(R.drawable.blueball_normal);
							button.setTextColor(getResources().getColor(R.color.white));
							button.setBackgroundResource(R.drawable.blueball_selected);
							holder.ballLayout.addView(button, layoutParams);
						}
					}
					// LayoutParams ivlayoutParams = new
					// LayoutParams(LayoutParams.WRAP_CONTENT,
					// LayoutParams.WRAP_CONTENT);
					// ivlayoutParams.gravity = Gravity.RIGHT|Gravity.BOTTOM;
					// ImageView ivrightarrow=new
					// ImageView(KjinfoListByType.this);
					// ivrightarrow.setBackgroundResource(R.drawable.common_right_arrow);
					// ivrightarrow.setPadding(0, 5, 10, 0);
					// holder.ballLayout.addView(ivrightarrow, ivlayoutParams);

				} else if (lotIdInt == LOT_ID_11X5 || lotIdInt == LOT_ID_11YDJ
						|| lotIdInt == LOT_ID_CQSSC) {
					convertView = inflater.inflate(R.layout.kjinfo_main_list_type_kuai3, null);
					holder.name = (TextView) convertView.findViewById(R.id.kjinfo_main_list_type_title);
					holder.endtime = (TextView) convertView.findViewById(R.id.kjinfo_item_right_endtime);
					holder.ballLayout = (LinearLayout) convertView.findViewById(R.id.kjinfo_item_ball_layout);
					String[] redBall = redBTemp.split(" ");
					for (String ball : redBall) {
						TextView button = (TextView) inflater.inflate(R.layout.kjinfo_item_ball, null);// kjinfo_item_ball
																										// kjinfo_item_ball_kuai3
						button.setText(ball);
						// button.setTextColor(getResources().getColor(R.color.ui_new_btn_yes_normal_solid));
						// button.setBackgroundResource(R.drawable.redball_normal);
						if (position == 0) {
							button.setTextColor(getResources().getColor(R.color.white));
							button.setBackgroundResource(R.drawable.redball_selected);
						} else {
							button.setTextColor(getResources().getColor(R.color.ui_new_btn_yes_normal_solid));
							button.setBackgroundResource(R.drawable.redball_normal);
						}
						holder.ballLayout.addView(button, layoutParams);
					}
					// String[] blueBall = blueBTemp.split(" ");
					// for (String ball : blueBall) {
					// if (ball != "") {
					// TextView button = (TextView)
					// inflater.inflate(R.layout.kjinfo_item_ball_kuai3, null);
					// button.setBackgroundResource(R.drawable.kjinfo_listbytype_kuai3_bg);//R.drawable.blueball1
					// button.setText(ball);
					// holder.ballLayout.addView(button, layoutParams);
					// }
					// }
				} else if(lotIdInt == LOT_ID_KUAI3 ){
					convertView = inflater.inflate(R.layout.kjinfo_main_list_type_kuai3, null);
					holder.name = (TextView) convertView.findViewById(R.id.kjinfo_main_list_type_title);
					holder.endtime = (TextView) convertView.findViewById(R.id.kjinfo_item_right_endtime);
					holder.ballLayout = (LinearLayout) convertView.findViewById(R.id.kjinfo_item_ball_layout);
					String[] redBall = redBTemp.split(" ");
					for (String ball : redBall) {
						TextView button = (TextView) inflater.inflate(R.layout.kjinfo_item_ball, null);// kjinfo_item_ball
						if (position == 0) {
							if (ball.equals("1")) {
								button.setBackgroundResource(R.drawable.kuai3_1);
							}else if(ball.equals("2")){
								button.setBackgroundResource(R.drawable.kuai3_2);
							}else if(ball.equals("3")){
								button.setBackgroundResource(R.drawable.kuai3_3);
							}else if(ball.equals("4")){
								button.setBackgroundResource(R.drawable.kuai3_4);
							}else if(ball.equals("5")){
								button.setBackgroundResource(R.drawable.kuai3_5);
							}else{
								button.setBackgroundResource(R.drawable.kuai3_6);
							}
						} else {
							button.setText(ball);
							button.setTextColor(getResources().getColor(R.color.ui_new_btn_yes_normal_solid));
							button.setTextSize(22);
//							button.setBackgroundResource(R.drawable.redball_normal);
						}
						LayoutParams kuai3_params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
						kuai3_params.gravity = Gravity.CENTER_VERTICAL;
						kuai3_params.rightMargin = 15;
						holder.ballLayout.addView(button, kuai3_params);
					}
				 }else {// R.layout.kjinfo_main_list_type_ssq
					convertView = inflater.inflate(R.layout.kjinfo_main_list_type, null);
					holder.name = (TextView) convertView.findViewById(R.id.kjinfo_main_list_type_title);
					holder.endtime = (TextView) convertView.findViewById(R.id.kjinfo_item_right_endtime);
					// holder.ballred = (TextView)
					// convertView.findViewById(R.id.kjinfo_main_list_type_info);
					// holder.ballblue = (TextView)
					// convertView.findViewById(R.id.kjinfo_main_list_type_info_blue);
					// holder.ballred.setText(redBTemp/*
					// * mData.get(position).get("Ball"
					// * ).toString()
					// */);
					// holder.ballblue.setText(blueBTemp/*
					// * mData.get(position).get(
					// * "BlueBall").toString()
					// */);
					holder.ballLayout = (LinearLayout) convertView.findViewById(R.id.kjinfo_item_ball_layout);
					String[] redBall = redBTemp.split(" ");
					for (String ball : redBall) {
						TextView button = (TextView) inflater.inflate(R.layout.kjinfo_item_ball, null);
						button.setText(ball);
						if (position == 0) {
							button.setTextColor(getResources().getColor(R.color.white));
							button.setBackgroundResource(R.drawable.redball_selected);
						} else {
							button.setTextColor(getResources().getColor(R.color.ui_new_btn_yes_normal_solid));
							button.setBackgroundResource(R.drawable.redball_normal);
						}
						holder.ballLayout.addView(button, layoutParams);
					}
					String[] blueBall = blueBTemp.split(" ");
					for (String ball : blueBall) {
						if (ball != "") {
							TextView button = (TextView) inflater.inflate(R.layout.kjinfo_item_ball, null);
							button.setText(ball);
							if (position == 0) {
								button.setTextColor(getResources().getColor(R.color.white));
								button.setBackgroundResource(R.drawable.blueball_selected);
							} else {
								button.setTextColor(getResources().getColor(R.color.ui_new_btn_no_normal_solid));
								button.setBackgroundResource(R.drawable.blueball_normal);
							}
							holder.ballLayout.addView(button, layoutParams);
						}
					}
					// if(lotIdInt == LOT_ID_SSQ){
					// LayoutParams ivlayoutParams = new
					// LayoutParams(LayoutParams.WRAP_CONTENT,
					// LayoutParams.WRAP_CONTENT);
					// ivlayoutParams.gravity =
					// Gravity.RIGHT|Gravity.CENTER_VERTICAL;
					// ImageView ivrightarrow=new
					// ImageView(KjinfoListByType.this);
					// ivrightarrow.setBackgroundResource(R.drawable.common_right_arrow);
					// ivrightarrow.setPadding(-5, 0, 5, 0);
					// holder.ballLayout.addView(ivrightarrow, ivlayoutParams);
					// }
				}
				holder.name.setText(mData.get(position).get("Issue").toString());
				// Log.d("kjtype", "mData= "+mData.toString());
				holder.endtime.setText(mData.get(position).get("EndTime").toString());
				convertView.setTag(holder);
			}

			return convertView;
		}

		class ViewHolder {
			TextView name;
			TextView endtime;
			TextView ballred;
			TextView ballblue;
			LinearLayout ballLayout;

			TextView kjinfo_item_yidjzhu;// 一等奖注数
			TextView kjinfo_item_yidjmoney;// 一等奖奖金
			TextView kjinfo_item_yidjjiangchi;// 奖池
		}

		class sfcViewHolder {
			TextView name;
			TextView endtime;
			TextView kjinfo_main_list_type_sfc1;
			TextView kjinfo_main_list_type_sfc2;
			TextView kjinfo_main_list_type_sfc3;
			TextView kjinfo_main_list_type_sfc4;
			TextView kjinfo_main_list_type_sfc5;
			TextView kjinfo_main_list_type_sfc6;
			TextView kjinfo_main_list_type_sfc7;
			TextView kjinfo_main_list_type_sfc8;
			TextView kjinfo_main_list_type_sfc9;
			TextView kjinfo_main_list_type_sfc10;
			TextView kjinfo_main_list_type_sfc11;
			TextView kjinfo_main_list_type_sfc12;
			TextView kjinfo_main_list_type_sfc13;
			TextView kjinfo_main_list_type_sfc14;
			LinearLayout ballLayout;
		}
	}

	@Override
	public void finish() {
		// TODO Auto-generated method stub
		super.finish();
		SysApplication.getInstance().removeActivity(this);
	};
}